package cn.yyt.yytravel.community.service.impl;

import cn.yyt.yytravel.community.mapper.CommentMapper;
import cn.yyt.yytravel.community.pojo.dto.CommentQuery;
import cn.yyt.yytravel.community.pojo.dto.CommentSaveParam;
import cn.yyt.yytravel.community.pojo.entity.Comment;
import cn.yyt.yytravel.community.pojo.vo.CommentVO;
import cn.yyt.yytravel.community.service.CommentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    CommentMapper commentMapper;

    @Override
    public void saveComment(CommentSaveParam commentSaveParam) {
        Comment comment = new Comment();
        BeanUtils.copyProperties(commentSaveParam,comment);
        comment.setCreateTime(new Date());
        commentMapper.insertComment(comment);
        System.out.println(comment);
    }

    @Override
    public List<CommentVO> selectComment(CommentQuery commentQuery) {
        List<CommentVO> list = commentMapper.selectComment(commentQuery);
        System.out.println("service" + list);
        return list;
    }
}
